package com.zhdl.websocket.client;


import lombok.extern.slf4j.Slf4j;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;

import java.net.URI;

/**
 * @Description:
 * @author: liu zhenming
 * @date: 2023/8/18 9:18
 */
@Slf4j
public class WebSocketClientExample extends WebSocketClient {


    public WebSocketClientExample(URI serverUri) {
        super(serverUri);
    }

    @Override
    public void onOpen(ServerHandshake serverHandshake) {
        log.info("websocket 客户端 onOpen");

    }

    @Override
    public void onMessage(String s) {
        log.info("websocket 客户端 message : {}", s);

    }

    @Override
    public void onClose(int i, String s, boolean b) {
        log.info("websocket 客户端 close");
    }

    @Override
    public void onError(Exception e) {
        log.error("websocket 客户端 error {}", e.getMessage());
    }


}
